<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <title>客户信息</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    <link rel="stylesheet" href="../layui-v2.6.8/layui/css/layui.css">
    <script type="text/javascript" src="../layui-v2.6.8/layui/layui.js"></script>
    <!-- 注意：如果你直接复制所有代码到本地，上述css路径需要改成你本地的 -->
</head>
<body>

<!--<blockquote class="layui-elem-quote layui-text">-->
<!--    鉴于小伙伴的普遍反馈，先温馨提醒两个常见“问题”：1. <a href="/doc/base/faq.html#form" target="_blank">为什么select/checkbox/radio没显示？</a> 2. <a href="/doc/modules/form.html#render" target="_blank">动态添加的表单元素如何更新？</a>-->
<!--</blockquote>-->

<fieldset class="layui-elem-field layui-field-title" style="margin-top: 20px;">
    <legend>客户信息管理</legend>
</fieldset>
<form class="layui-form" action="">
    <div class="layui-form-item">
        <label class="layui-form-label">姓名</label>
        <div class="layui-input-inline">
            <input type="text" id="cname" required lay-verify="required" placeholder="请输入姓名" autocomplete="off" class="layui-input">
        </div>
        <!--        <div class="layui-form-mid layui-word-aux">辅助文字</div>-->
    </div>
<!--    <div class="layui-form-item">-->
<!--        <label class="layui-form-label">客户编号</label>-->
<!--        <div class="layui-input-inline">-->
<!--            <input type="text" name="cid" required lay-verify="required" placeholder="请输入编号" autocomplete="off" class="layui-input">-->
<!--        </div>-->
<!--        &lt;!&ndash;        <div class="layui-form-mid layui-word-aux">辅助文字</div>&ndash;&gt;-->
<!--    </div>-->
    <div class="layui-form-item">
        <label class="layui-form-label">联系方式</label>
        <div class="layui-input-inline">
            <input type="text" id="cphone" required lay-verify="required" placeholder="请输入联系方式" autocomplete="off" class="layui-input">
        </div>
        <!--        <div class="layui-form-mid layui-word-aux">辅助文字</div>-->
    </div>
    <!--    <div class="layui-form-item">-->
    <!--        <label class="layui-form-label">地址</label>-->
    <!--        <div class="layui-input-inline">-->
    <!--            <input type="password" name="password" required lay-verify="required" placeholder="请输入密码" autocomplete="off" class="layui-input">-->
    <!--        </div>-->
    <!--        &lt;!&ndash;        <div class="layui-form-mid layui-word-aux">辅助文字</div>&ndash;&gt;-->
    <!--    </div>-->
<!--    <div class="layui-form-item">-->
<!--        <label class="layui-form-label">地址</label>-->
<!--        <div class="layui-input-block">-->
<!--            <input type="text" name="String" required  lay-verify="required" placeholder="请输入地址" autocomplete="off" class="layui-input">-->
<!--        </div>-->
<!--    </div>-->

    <!--    <div class="layui-form-item">-->
    <!--        <label class="layui-form-label">复选框</label>-->
    <!--        <div class="layui-input-block">-->
    <!--            <input type="checkbox" name="like[write]" title="写作">-->
    <!--            <input type="checkbox" name="like[read]" title="阅读" checked>-->
    <!--            <input type="checkbox" name="like[dai]" title="发呆">-->
    <!--        </div>-->
    <!--    </div>-->

    <!--    <div class="layui-form-item">-->
    <!--        <label class="layui-form-label">单选框</label>-->
    <!--        <div class="layui-input-block">-->
    <!--            <input type="radio" name="sex" value="男" title="男">-->
    <!--            <input type="radio" name="sex" value="女" title="女" checked>-->
    <!--        </div>-->
    <!--    </div>-->
<!--    <div class="layui-form-item layui-form-text">-->
<!--        <label class="layui-form-label">备注</label>-->
<!--        <div class="layui-input-block">-->
<!--            <textarea name="desc" placeholder="请输入内容" class="layui-textarea"></textarea>-->
<!--        </div>-->
<!--    </div>-->
    <div class="layui-form-item">
        <div class="layui-input-block">
            <button class="layui-btn" onclick="insert_1()" >添加</button>
            <!--            <button type="reset" class="layui-btn layui-btn-primary">重置</button>-->
        </div>
    </div>
</form>
<script src="../layui-v2.6.8/layui/layui.js"></script>
<script type="text/javascript">

    function insert_1(){
        var $ = layui.$;
        var cname =$("#cname").val();
        var cphone =$("#cphone").val();
        console.log(cname);
        var data ={
            "cname":cname,
            "cphone":cphone,
        }
        var url ="http://localhost:8080/add";
        $.ajax({
            type:"get",
            url:url,
            async:false,
            cache:false,
            data:data,
            success: function(data,textStaus,jqXHR){

                if(data.code === 200){
                    alert("插入成功了");
                }else{
                    alert(data.message);
                }
            },
            error:function (XMLHttpRequest, textStatus, errorThrown) {

                alert(typeof(errorThrown));
            }
        });
    }
</script>
